<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="https://unpkg.com/vue@next"></script>
</head>

<body>
    <div id="app"></div>
</body>
<script>
    // 生命周期函数   在某一时刻会自动执行的函数
    const app = Vue.createApp({//application 创建一个Vue应用
        data() {
            return {
                message: 'bilibili',
            }
        },
        methods: {
            handleitemclick() {
                this.message = this.message == 'hello world!' ? '你好世界' : 'hello world!'
            }
        },
        template: `
        <h2 @click="handleitemclick" v-if="message=='hello world!'" class="one">{{message}}</h2>
        <h2 @click="handleitemclick" v-if="message=='你好世界'" class="two">{{message}}</h2>
        <h2 @click="handleitemclick" v-if="message=='bilibili'" class="three">{{message}}</h2>
        `
    })
    const vm = app.mount("#app")//挂载这个Vue应用
</script>
<style>
    .one {
        color: red;
    }

    .two {
        color: green;
    }

    .three {
        color: greenyellow;
    }
</style>

</html>